
import { viteMockServe } from 'vite-plugin-mock'
import {IS_USE_MOCK} from "../constant";

export default function createMockPlugin(){
    return viteMockServe({
        ignore: /^\_/,
        mockPath: 'mock',
        localEnabled: IS_USE_MOCK, // 开发打包开关 是否开启mock
        prodEnabled: false, // 打包模式关闭mock
        // 项目初始化时 main.ts 中注入此段代码 加载所有mock文件
        injectCode: `
            import { setupProdMockServer } from '../mock/_createProdMockServer';
            setupProdMockServer();
        `,
    })
}
